# -*- coding: utf-8 -*-
# @Time : 2021/9/17 19:29
# @Author : 伟哥
# @Email : xw@gmail.com
# @File : MRYX_WD_004.py.py
# @Project : mryx_test
'''验证清除缓存功能'''
from time import sleep
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy as By


desired_capabilities={
    "platformName":"Android",
    "deviceName":"127.0.0.1:62001",
    "platformVersion":"7.1.2",
    "appPackage": "cn.missfresh.application",
    "appActivity":"cn.missfresh.module.main.view.MainActivity",
    "noReset":"True"
}
driver=webdriver.Remote("http://localhost:4723/wd/hub",desired_capabilities)
driver.implicitly_wait(60)
try:
    my_locator=(By.XPATH,'//android.widget.TextView[@resource-id=\"cn.missfresh.application:id/mineTab\"]')
    set_locator=(By.XPATH,'//android.widget.ImageView[@content-desc=\"设置\"]')
    clear_locator=(By.XPATH,'//android.widget.ImageView[@content-desc=\"清除缓存\"]')
    assertion_locator=(By.XPATH,'//*[contains(text(),"清除了")]')
    # 点击我的
    sleep(5)
    driver.find_element(*my_locator).click()
    #点击设置
    sleep(2)
    driver.find_element(*set_locator).click()
    #点击清除缓存
    sleep(2)
    wait = WebDriverWait(driver, 10, 0.3)
    driver.find_element(*clear_locator).click()
    #断言
    clear=wait.until(EC.presence_of_element_located(assertion_locator))
    print(clear.text)
except Exception:
    raise
finally:
    sleep(5)
    driver.quit()